package com.heima.utils.thread;

import com.heima.model.admin.pojos.AdminUser;

/**
 * @author:Dikk
 * @create: 2023-07-21 17:39
 * @DescriptAdminUreadLocalUtils
 */
public class AdminThreadLocalUtils {

    public static final ThreadLocal<AdminUser> ADMIN_USER_THREAD_LOCAL = new ThreadLocal<>();

    /**
     * 添加用户
     *
     * @param adminUser
     */
    public static void setUser(AdminUser adminUser) {
        ADMIN_USER_THREAD_LOCAL.set(adminUser);
    }

    /**
     * 获取用户
     */
    public static AdminUser getUser() {
        return ADMIN_USER_THREAD_LOCAL.get();
    }

    /**
     * 清理用户
     */
    public static void clear() {
        ADMIN_USER_THREAD_LOCAL.remove();
    }
}
